<form [formGroup]="formGroup" [bitSubmit]="load">
  <bit-callout *ngIf="hideEmail" type="warning" title="{{ 'warning' | i18n }}">
    {{ "viewSendHiddenEmailWarning" | i18n }}
    <a bitLink href="https://bitwarden.com/help/receive-send/" target="_blank" rel="noreferrer">{{
      "learnMore" | i18n
    }}</a
    >.
  </bit-callout>
  <ng-container *ngIf="!loading; else spinner">
    <app-send-access-password
      (setPasswordEvent)="setPassword($event)"
      *ngIf="passwordRequired && !error"
    ></app-send-access-password>
    <div class="tw-text-main tw-text-center" *ngIf="unavailable">
      <p bitTypography="body1">{{ "sendAccessUnavailable" | i18n }}</p>
    </div>
    <div class="tw-text-main tw-text-center" *ngIf="error">
      <p bitTypography="body1">{{ "unexpectedErrorSend" | i18n }}</p>
    </div>
    <div *ngIf="!passwordRequired && send && !error && !unavailable">
      <p class="tw-text-center">
        <b>{{ send.name }}</b>
      </p>
      <hr />
      <!-- Text -->
      <ng-container *ngIf="send.type === sendType.Text">
        <app-send-access-text [send]="send"></app-send-access-text>
      </ng-container>
      <!-- File -->
      <ng-container *ngIf="send.type === sendType.File">
        <app-send-access-file
          [send]="send"
          [decKey]="decKey"
          [accessRequest]="accessRequest"
        ></app-send-access-file>
      </ng-container>
      <p *ngIf="expirationDate" class="tw-text-center tw-text-muted">
        Expires: {{ expirationDate | date: "medium" }}
      </p>
    </div>
  </ng-container>
  <ng-template #spinner>
    <div class="tw-text-center">
      <i
        class="bwi bwi-spinner bwi-spin bwi-2x tw-text-muted"
        title="{{ 'loading' | i18n }}"
        aria-hidden="true"
      ></i>
      <span class="tw-sr-only">{{ "loading" | i18n }}</span>
    </div>
  </ng-template>
</form>
